package com.cty.queue;

import java.util.Scanner;

/**
 * 对数组队列的测试
 */

public class ArrayQueueDemo {
    public static void main(String[] args) {
        //测试数组队列的最大容量为3
        ArrayQueue queue = new ArrayQueue(3);
        char key =' ';
        Scanner scanner = new Scanner(System.in);
        boolean loop =true;
        while(loop){
            System.out.println("a(addData):添加数据");
            System.out.println("g(getData):获取数据");
            System.out.println("e(exit):退出程序");
            System.out.println("h(headData):获取头数据");
            System.out.println("l(listData):查看全部数据");
            System.out.print("请输入执行功能:");
            key=scanner.next().charAt(0);
            switch (key) {
                case 'a':
                    System.out.print("请输入你要添加的数据:");
                    int num=scanner.nextInt();
                    queue.addQueue(num);
                    break;
                case 'g':
                    try {
                        int data = queue.getQueue();
                        System.out.println("获取的数据是："+data);
                    } catch (Exception e) {
                        System.out.println(e.getMessage());
                    }
                    break;
                case 'e':
                    System.out.println("退出程序~~");
                    loop=false;
                    break;
                case 'h':
                    try {
                        int peek = queue.peek();
                        System.out.println("头数据："+peek);
                    } catch (Exception e) {
                        System.out.println(e.getMessage());
                    }
                    break;
                case 'l':
                    queue.ListQueue();
                    break;
            }
        }
    }
}
